package cn.kkcxy.blog.system.service.impl.article;

import cn.kkcxy.blog.core.entity.article.ArticleCategory;
import cn.kkcxy.blog.core.vo.client.archive.category.ClientCommonArticleCategoryVO;
import cn.kkcxy.blog.system.mapper.article.ArticleCategoryMapper;
import cn.kkcxy.blog.system.service.article.ArticleCategoryService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;

import java.util.List;

/**
* @author kk
* @description 针对表【article_category】的数据库操作Service实现
* @createDate 2024-09-18 00:25:54
*/
@Service
public class ArticleCategoryServiceImpl extends ServiceImpl<ArticleCategoryMapper, ArticleCategory> implements ArticleCategoryService {

    /**
     * Article Category Mapper
     */
    @Resource
    private ArticleCategoryMapper articleCategoryMapper;

    /**
     * @description: [用户端] 获取文章分类数据
     * @author: kkcxy
     * @date: 2024/9/27 1:38
     * @param: []
     * @return: java.util.List<cn.kkcxy.blog.core.vo.client.archive.category.ClientSecondLevelArticleCategoryVO>
     **/
    @Override
    public List<ClientCommonArticleCategoryVO> getArticleCategories(Long parentId, Integer categoryType, Integer deleted) {
        return articleCategoryMapper.getArticleCategories(parentId, categoryType, deleted);
    }

    /**
     * @description: 根据一级分类ID获取该分类下所有子分类ID
     * @author: kkcxy
     * @date: 2024/9/27 22:58
     * @param: [primaryCategoryId]
     * @return: java.util.List<java.lang.Long>
     **/
    @Override
    public List<Long> getSecondLevelCategoryIdsByPrimaryCategoryId(Long primaryCategoryId) {
        return articleCategoryMapper.getSecondLevelCategoryIdsByPrimaryCategoryId(primaryCategoryId);
    }

    /**
     * @description: 根据分类id获取文章分类下文章数
     * @author: kkcxy
     * @date: 2024/9/27 23:32
     * @param: [ids]
     * @return: java.util.List<cn.kkcxy.blog.core.vo.client.archive.category.ClientCommonArticleCategoryVO>
     **/
    @Override
    public List<ClientCommonArticleCategoryVO> getArticleCategoryCountListByCategoryIds(List<Long> ids) {
        return articleCategoryMapper.getArticleCategoryCountListByCategoryIds(ids);
    }

    /**
     * @description: 获得分类总数
     * @author: kkcxy
     * @date: 2024/9/28 23:59
     * @param: []
     * @return: java.lang.Integer
     **/
    @Override
    public Integer getCategoryCount() {
        return articleCategoryMapper.getCategoryCount();
    }
}




